import requests

cookies = {
    'QCCSESSID': '0c65790e54b5b7c1751c744a35',
    'qcc_did': '9f81be1e-7f08-4458-ba7e-2131e92bc365',
    'UM_distinctid': '1977d0ef583100f-023c7543b8ed838-4c657b58-1fa400-1977d0ef5842091',
    'tfstk': 'gXnsMfmui1fsIXZAhPvFA6at9zrjlp-zGtwxExINHlEOMsH8TRowsxFjGXPnGrvggSFjgx3wL3-rIAq0DjOy43PtX73m1OeTkKeLh8pUBMJcfrq0DQRU503kKocOI-gnMvpQ3-SODjFAJ9F3B1EY6rCdJ8FLDoUTD9CLe-IOW5F9dvF3HoFxMopQvW2xCZW7hFNiCduM_xPpyjDTOiIxXn4gNaVLKJnQCPN8JWsx5Dw_57HtVE9MxJnEAzzF3BZKE2lTdut1ZRgKFlejmLQbGrigA-gH1NlSs-HLRfJVoJgjH0qgVtKtdlN_ymGdeMG-dx3zRDJJqlZT6qri3TOZdcGZIDMVHwE_b2aSfuKl6SuEFmwjmIxINxHokyif1g5P479HpZ6QriwQap9CoZbC6_M9nDsmqPe3CyJBd130WJ2Qap9CoZ4TKRwydp1to',
    'acw_tc': '1a0c39d717515055689668649e005ed18f16c3f1e8e3984d797ecb9151619b',
    'CNZZDATA1254842228': '2093331597-1750149822-https%253A%252F%252Fcn.bing.com%252F%7C1751506583',
}

headers = {
    '278fcd3b10ae73561ab2': 'b071b4deee58f767baf7b751d75e5a1327becbf53f271218629bd6a66bfa424ddc039c5fe378307efd61061a2f10a4559a0ac3271ae7c48d3344bbc2a73afc5b',
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'priority': 'u=1, i',
    'referer': 'https://www.qcc.com/web/project/batchList?batchType=1',
    'sec-ch-ua': '"Not)A;Brand";v="8", "Chromium";v="138", "Microsoft Edge";v="138"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0',
    'x-pid': '9f4c6830b63fd6ebc5c4d509351b23d4',
    'x-requested-with': 'XMLHttpRequest',
    # 'cookie': 'QCCSESSID=0c65790e54b5b7c1751c744a35; qcc_did=9f81be1e-7f08-4458-ba7e-2131e92bc365; UM_distinctid=1977d0ef583100f-023c7543b8ed838-4c657b58-1fa400-1977d0ef5842091; tfstk=gXnsMfmui1fsIXZAhPvFA6at9zrjlp-zGtwxExINHlEOMsH8TRowsxFjGXPnGrvggSFjgx3wL3-rIAq0DjOy43PtX73m1OeTkKeLh8pUBMJcfrq0DQRU503kKocOI-gnMvpQ3-SODjFAJ9F3B1EY6rCdJ8FLDoUTD9CLe-IOW5F9dvF3HoFxMopQvW2xCZW7hFNiCduM_xPpyjDTOiIxXn4gNaVLKJnQCPN8JWsx5Dw_57HtVE9MxJnEAzzF3BZKE2lTdut1ZRgKFlejmLQbGrigA-gH1NlSs-HLRfJVoJgjH0qgVtKtdlN_ymGdeMG-dx3zRDJJqlZT6qri3TOZdcGZIDMVHwE_b2aSfuKl6SuEFmwjmIxINxHokyif1g5P479HpZ6QriwQap9CoZbC6_M9nDsmqPe3CyJBd130WJ2Qap9CoZ4TKRwydp1to; acw_tc=1a0c39d717515055689668649e005ed18f16c3f1e8e3984d797ecb9151619b; CNZZDATA1254842228=2093331597-1750149822-https%253A%252F%252Fcn.bing.com%252F%7C1751506583',
}

params = {
    'batchType': '0',
}

response = requests.get('https://www.qcc.com/api/batch/getBatchRedis', params=params, cookies=cookies, headers=headers)



data_url = response.json()
data_urllist = []
for i in data_url['data']:
    with open('./qichacha_url.txt', 'a+', encoding='utf-8') as f:
        f.write(f'https://www.qcc.com/cassets/{i['KeyNo']}.html\n')
        # https://www.qcc.com/cassets/27505d1266d23b6d705c5979da848d75.html
# for x in data_url['data']:
#     with open('./qichacha_code.txt', 'a+', encoding='utf-8') as f:
#         f.write(f'{x['Name']}\n')
